﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DelegateDemo2
{
    class Program
    {
        delegate int Transformer(int x);
        static int Square(int x)
        {
            var result=x* x;
            Console.WriteLine(result);
            return result;
        }

        static int Cube(int x)
        {
            var result = x * x * x;
            Console.WriteLine(result);
            return result;
        } 
        static void Main(string[] args)
        {
            Transformer transformer = null;
            transformer += Square;
            transformer += Cube;
            //transformer -= Square;
            var result = transformer(3);
            //使用最后一个方法作为返回值，前面的一个被弃用了
            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}
